const {
  getMessageList
} = require("../../../api/api.js");
const {fly} = require("../../../api/request.js");
const { _navigateTo } = require("../../../utils/util.js");
const { SYSTEM_MSG } = require("../../../utils/type.js");
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    MessageList: [],
    imgHost:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    app.getHost().then(({
      host,
      img_host
    }) => {
      fly.config.baseURL = host;
      this.setData({
        imgHost: img_host
      })

      /**
       *  系统消息数据
       */
      getMessageList(SYSTEM_MSG).then(res => {
        console.log(res)
        this.setData({
          MessageList: res.data
        })
        console.log(res)
      }).catch(err => {
        console.log(err)
      })

    })
  },
  //跳转消息详情页
  toMsgDetail(e){
    const { content, time, title } = e.currentTarget.dataset;
    _navigateTo(`../common_detail/index?content=${content}&time=${time}&title=${title}`);
  }
})